package com.heima.article.task;


import com.heima.article.service.IHotArticleService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class HotArticleTask {

    @Autowired
    private IHotArticleService articleService;

    @XxlJob("computeHotArticleJob")
    public ReturnT<String> computeHotArticleJob(String param) throws Exception {

        log.info("开始执行每日文章分值计算任务");

        try {
            articleService.compute();
        } catch (Exception e) {

            log.error(e.getMessage());

            return ReturnT.FAIL;
        }
        return ReturnT.SUCCESS;
    }
}
